/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import java.util.Date;
import javax.naming.InitialContext;
import rental.ReservationConstraints;
import session.CarRentalSessionRemote;
import session.ManagerSessionRemote;

/**
 *
 * @author wouterdb
 */
public class Main extends AbstractScriptedTripTest<CarRentalSessionRemote, ManagerSessionRemote> {

    public Main(String scriptFile) {
        super(scriptFile);
    }

    public static void main(String[] args) throws Exception {
        //TODO: use updated manager interface to load cars into companies
        new Main("trips").run();
    }

    @Override
    protected void addQuoteToSession(CarRentalSessionRemote session, Date start, Date end, String carType, String carRentalName) throws Exception {
        session.createQuote(carRentalName, new ReservationConstraints(start, end, carType));
    }

    @Override
    protected void confirmQuotes(CarRentalSessionRemote session) throws Exception {
        session.confirmQuotes();
    }

    @Override
    protected CarRentalSessionRemote getNewClientSession(String name) throws Exception {
        CarRentalSessionRemote out = (CarRentalSessionRemote) new InitialContext().lookup("java:global/CarRental/CarRental-ejb/CarRentalSession");
        out.setClientName(name);
        return out;
    }

    @Override
    protected ManagerSessionRemote getNewManagerSession(String name, String carRentalName) throws Exception {
        ManagerSessionRemote out = (ManagerSessionRemote) new InitialContext().lookup("java:global/CarRental/CarRental-ejb/ManagerSession");
        return out;
    }

    @Override
    protected int getReservationsForCarType(ManagerSessionRemote ms, String name, String carType) throws Exception {
        return ms.getReservations(name, carType).size();
    }
}